Vue.directive('clickoutside', {
    bind: function (el, binding, vnode) {
        function documentHandler(e) {
            if (el.contains(e.target)) {
                return false;
            }
            if (binding.expression) {
                binding.value();
            }
        }
		el._vueClickOutside_ = documentHandler;
		document.addEventListener('click',documentHandler)
// 		function keyupHandler(e){
// 			if(27 === e.keyCode){
// 				if (binding.expression) {
// 					binding.value();
// 				}
// 			}
// 		}
// 		el._vueClickOutside_esc = keyupHandler;
// 		document.addEventListener('keyup',keyupHandler)
    },
    unbind: function (el, binding) {
        document.removeEventListener('click', el._vueClickOutside_);
        delete el._vueClickOutside_;
// 		document.removeEventListener('click', el._vueClickOutside_esc);
// 		delete el._vueClickOutside_esc;
    }
})
